<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<h:head>
</h:head>


<h:body>
	<ui:composition template="/template/common/commonLayout.xhtml">

		<ui:define name="content">
			<h:form id="form">
				<!-- Mini popup -->
				<p:growl id="growl" showDetail="true" />


				<p:dataTable id="dataTable" var="p" value="#{projet.listProjet}"
					paginator="true" rows="10" editable="true"
					filteredValue="#{projet.filteredProjet}"
					selection="#{projet.selectedProjet}" selectionMode="single"
					rowKey="#{p.id}">
					<p:ajax event="rowSelect" listener="#{projet.onRowSelect}"
						update=":form:display :form:growl"
						oncomplete="PF('projetDialog').show()" />
					<p:ajax event="rowUnselect" listener="#{projet.onRowUnselect}"
						update=":form:growl" />
					<p:ajax event="rowEdit" listener="#{projet.onEdit}"
						update=":form:growl" />
					<p:ajax event="rowEditCancel" listener="#{projet.onCancel}"
						update=":form:growl" />
					<f:facet name="header">
			liste des projets
			</f:facet>
					<p:column sortBy="id" headerText="ID" filterBy="id"
						filterMatchMode="contains">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{p.id}" />
							</f:facet>
							<f:facet name="input">
								<h:inputText value="#{p.id}" />
							</f:facet>
						</p:cellEditor>
					</p:column>
					<p:column sortBy="nom" headerText="Nom" filterBy="nom"
						filterMatchMode="contains">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{p.nom}" />
							</f:facet>
							<f:facet name="input">
								<h:inputText value="#{p.nom}" />
							</f:facet>
						</p:cellEditor>
					</p:column>
					<p:column sortBy="dateDebut" headerText="Date Debut"
						filterBy="dateDebut" filterMatchMode="contains">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{p.dateDebut}" />
							</f:facet>
							<f:facet name="input">
								<h:inputText value="#{p.dateDebut}" />
							</f:facet>
						</p:cellEditor>
					</p:column>
					<p:column sortBy="dateFin" headerText="Date Fin" filterBy="dateFin"
						filterMatchMode="contains">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{p.dateFin}" />
							</f:facet>
							<f:facet name="input">
								<h:inputText value="#{p.dateFin}" />
							</f:facet>
						</p:cellEditor>
					</p:column>
					<p:column sortBy="etat" headerText="Etat" filterBy="etat"
						filterMatchMode="contains">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{p.etat}" />
							</f:facet>
							<f:facet name="input">
								<h:inputText value="#{p.etat}" />
							</f:facet>
						</p:cellEditor>
					</p:column>

					<p:column headerText="Edition" style="width:50px">
						<p:rowEditor />
					</p:column>
				</p:dataTable>

				<!-- Popup Fiche projet électionné -->
				<p:dialog id="projetDialog" header="Fiche Projet"
					widgetVar="projetDialog" resizable="false" showEffect="fade"
					hideEffect="explode">

					<h:panelGrid id="display" columns="2" cellpadding="4">


						<h:outputText value="ID :" />
						<h:outputText value="#{projet.selectedProjet.id}" />

						<h:outputText value="Nom :" />
						<h:outputText value="#{projet.selectedProjet.nom}" />

						<h:outputText value="Date de debut :" />
						<h:outputText value="#{projet.selectedProjet.dateDebut}" />

						<h:outputText value="Date de Fin :" />
						<h:outputText value="#{projet.selectedProjet.dateFin}" />


						<p:dataTable id="dataTableEtapeProjetForProjet" var="e"
							value="#{etapeProjet.getEtapeProjetForProjet(projet.selectedProjet.id)}"
							editable="false"
							filteredValue="#{etapeProjet.filteredEtapeProjet}"
							selection="#{etapeProjet.selectedEtapeProjet}"
							selectionMode="single" rowKey="#{e.id}">
							<f:facet name="header">
			liste des projets
			</f:facet>

							<p:column>

								<p:cellEditor>
									<f:facet name="output">
										<h:outputText value="#{e.nom}" />
									</f:facet>
									<f:facet name="input">
										<h:inputText value="#{e.nom}" />
									</f:facet>
								</p:cellEditor>

							</p:column>
						</p:dataTable>




					</h:panelGrid>
				</p:dialog>

				<h:panelGrid columns="1" cellpadding="5">
					<p:commandButton id="ajoutDialogButton" value="Ajouter"
						onclick="PF('dlg').show();" type="button" />
				</h:panelGrid>
				<p:dialog id="ajoutDialog" header="Ajout d'un projet"
					widgetVar="dlg" modal="false" resizable="false">
					<p:panel id="panel" style="margin-bottom:10px;">
						<p:messages id="messages" />
						<h:panelGrid columns="3">
							<h:outputLabel for="nom" value="Nom : *" />
							<p:inputText id="nom" value="#{projet.nom}" required="true"
								label="Nom">
								<f:validateLength minimum="2" />
							</p:inputText>
							<p:message for="nom" />
							<h:outputLabel for="dateDebut" value="Date Debut :" />
							<p:inputText id="dateDebut" value="#{projet.dateDebut}"
								label="Date Debut">
								<f:validateLength minimum="2" />
							</p:inputText>
							<p:message for="dateDebut" />
							<h:outputLabel for="dateFin" value="Date Fin :" />
							<p:inputText id="dateFin" value="#{projet.dateFin}"
								label="Date Fin">
								<f:validateLength minimum="2" />
							</p:inputText>
							<p:message for="dateFin" />
							<h:outputLabel for="etat" value="Etat :" />
							<p:inputText id="etat" value="#{projet.etat}" label="Etat" />
							<p:message for="etat" />

						</h:panelGrid>
					</p:panel>

					<p:commandButton value="Enregistrer"
						actionListener="#{projet.insertProjet()}"
						oncomplete="PF('dlg').hide()" id="enregistrer"
						update="panel,dataTable" icon="ui-icon-disk" ajax="true" />
				</p:dialog>
			</h:form>


		</ui:define>
	</ui:composition>
</h:body>


</html>
